/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tools;

import java.sql.Connection;
import java.sql.DriverManager;

import java.sql.SQLException;


/**
 *
 * @author w7
 */
public class koneksi1 {


//
// pilih koneksi yang sesuai
//    static String jdbcURL = "jdbc:oracle:thin:@localhost:1521:XE";
//    static String user = "spp";
//    static String password = "spp";
//    static Connection connection;
    
    static String jdbcURL = "jdbc:mysql://localhost:3306/sms";
    static String user = "root";
    static String password = "";
    static Connection connection;
////



    public koneksi1() {
        
    }

    public static Connection getDBConnection() throws Exception {

        if (connection == null) {
            Class.forName("org.gjt.mm.mysql.Driver");
            connection = DriverManager.getConnection(jdbcURL, user, password);
        
        }
        return connection;
    }

    public void close() {
        try {
            connection.close();
        } catch (SQLException ex) {
            System.out.println("Tidak bisa tutup kembali");
        }
    }

    public static void main(String[] args) throws Exception {
        koneksi1 conn = new koneksi1();
        koneksi1.getDBConnection();
        conn.close();

    }
}
